<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
                // 页面加载时初始化一个值
                let i = 1;
                $("#more").click(function () {
                    let d = $("#d").clone(true);
                    d.attr("id", "d" + i);
                    $(this).before(d);
                    // 将新增区域的文件选择器的值清除
                    $("#d" + i + " input").val("");
                    i++;
            })

            $("a").click(function () {
                if ($(this).parent().attr("id") != "d") {
                    $(this).parent().remove();
                }
            })
        })
    </script>
</head>
<body>
<div id="d">
    <input type="file">
    <a href="javascript:;">删除</a>
</div>
<button id="more">上传更多</button>
</body>
</html>